#!/bin/zsh

current_user_id=$(stat -f%u /dev/console)

if [ $current_user_id -ne 0 ]
then
        is_agent_running=$(launchctl asuser $current_user_id launchctl list | grep "com.filewave.blockmacosinstall.notifier"$)

        if [ $? -ne 0 ]
        then
                launchctl asuser $current_user_id launchctl load /Library/LaunchAgents/com.filewave.blockmacosinstall.notifier.plist
        fi
fi

is_daemon_running=$(launchctl list | grep "com.filewave.blockmacosinstall"$)
if [ $? -ne 0 ]
then
	launchctl load /Library/LaunchDaemons/com.filewave.blockmacosinstall.plist
fi

exit 0